{extend name="app/admin/view/base.html"/}
{block name="resources"}
{/block}
{block name="main"}
<div class="layui-collapse ns-tips">
    <div class="layui-colla-item">
        <h2 class="layui-colla-title">操作说明</h2>
        <ul class="layui-colla-content layui-show">
            <li>本配置用于PC端商城客服和H5端商城客服</li>
            <li>配置保存后需重新刷新部署才能应用（适用于默认部署，其他方式部署请自行配置WS链接）</li>
        </ul>
    </div>
</div>

<div class="layui-form ns-form">

    <div class="layui-form-item">
        <label class="layui-form-label">websocket链接：</label>
        <div class="layui-input-block">
            <input type="text" name="web_socket" value="{$config.web_socket ?? ''}" autocomplete="off" class="layui-input ns-len-long">
        </div>
    </div>
    <div class="ns-form-row">
        <button class="layui-btn ns-bg-color" lay-submit lay-filter="save">保存</button>
    </div>
</div>
{/block}
{block name="script"}
<script>
    layui.use('form', function () {
        var form = layui.form,
            repeat_flag = false; //防重复标识
        form.render();

        form.on('submit(save)', function (data) {
            if (repeat_flag) return;
            repeat_flag = true;

            $.ajax({
                type: 'POST',
                dataType: 'JSON',
                url: ns.url("servicer://admin/config/config"),
                data: data.field,
                success: function (res) {
                    if (res.code == 0) {
                        layer.msg(res.message);
                    } else {
                        repeat_flag = false;
                        layer.msg(res.message);
                    }
                }
            });
        });

    });

</script>
{/block}